#include "headfile.h"

void ADC_GM_Init(void)
{
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
	
	GPIO_InitTypeDef GPIO_Struct;
	GPIO_Struct.GPIO_Mode = GPIO_Mode_AN;
	GPIO_Struct.GPIO_Pin = GPIO_Pin_0;
	GPIO_Struct.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Struct.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA,&GPIO_Struct);
	
	ADC_CommonInitTypeDef ADC1_Common_Struct;
	ADC1_Common_Struct.ADC_Mode = ADC_Mode_Independent;
	ADC1_Common_Struct.ADC_Prescaler = ADC_Prescaler_Div4;
	ADC_CommonInit(&ADC1_Common_Struct);
	
	ADC_InitTypeDef ADC1_Struct;
	ADC1_Struct.ADC_Resolution = ADC_Resolution_12b;
	ADC1_Struct.ADC_ScanConvMode = DISABLE;
	ADC1_Struct.ADC_ContinuousConvMode = DISABLE;
	ADC1_Struct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
	ADC1_Struct.ADC_DataAlign = ADC_DataAlign_Right;
	ADC1_Struct.ADC_NbrOfConversion = 1;
	ADC_Init(ADC1,&ADC1_Struct); 
	
	ADC_Cmd(ADC1,ENABLE);
	
}
